<!DOCTYPE html>
<html lang="en">
  <head>
    <?php echo Yaf_View_Simple::render('header.phtml'); ?>
    <script type="text/javascript">
     var app = {
         article_rows : <?php echo $count[0]; ?>
     }
    </script>
    
  </head>
  <body data-target=".bs-docs-sidebar">
	<?php echo Yaf_View_Simple::render('nav.phtml'); ?>
	<div class="container">
      <div class="page-header">
        <h2><?php echo $category['name']; ?></h2>
      </div>      
	  <div class="row">

		<div class="col-lg-12">
		  <table class="table table-condensed">
			<thead>
			  <tr>
				<th>Title</th>
				<th>Description</th>
				<th>Auther</th>
				<th>Date</th>
			  </tr>
			</thead>
			<tbody id="tbody">
			  <?php foreach($articles as $value) { ?>
			  <tr>
				<td><a href="/index/article/post?id=<?php echo $value['id']; ?>"><?php echo $value['title']; ?></a></td>
				<td><?php echo $value['description']; ?></td>
				<td><?php echo $value['author']; ?></td>
				<td><?php echo $value['create_time']; ?></td>
			  </tr>								
			  <?php } ?>
			</tbody>
		  </table>
		  <div class="pagination" id ="pagination">
			<ul>
			</ul>
		  </div>
		</div>				
	  </div>

	</div>
	
	<footer class="footer">
	  <?php echo Yaf_View_Simple::render('footer.phtml'); ?>
	</footer>
	<script>

	</script>
	<!-- <script src="/asset/index/js/pagination.js" type="text/javascript"></script> -->
	<script src="/asset/index/js/ajaxpage.js" type="text/javascript"></script>
    <script type="text/javascript">
     ;(function(){
         var bind = function(){
             var pagination = $("#pagination");
             var _a = pagination.find("li a");
             _a.on('click',function(){
                 
                 // console.log("nice");
                 var page = $(this).text();
                 page = parseInt(page);
                 if(page == 1){
                     page = 0;
                 }else{
                     page = (page-1)*10;
                 }
                 $.ajax({
                     type:"post",
                     url :"/index/category/page",
                     data:{page : page},
                     success:function(e){
                         $("#tbody").html(e)
                         // console.log(e);
                     },
                     dataType: 'text',
                 });            
             })

         }
         bind();
         
     }())
    </script>
  </body>
</html>

